//
//  ViewController.swift
//  Segment_swift
//
//  Created by CarlsonLee on 2020/4/24.
//  Copyright © 2020 CarlsonLee. All rights reserved.
//

import UIKit
import SnapKit

class ViewController: UIViewController, SegmentManagerDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        
        initSubviews()
    }

    func initSubviews() {
        let segment = SegmentManager(frame: CGRect.zero, delegate: self)
        view.addSubview(segment)
        segment.snp.makeConstraints(){
            $0.top.equalToSuperview().offset(30)
            $0.left.equalToSuperview().offset(0)
            $0.right.equalToSuperview().offset(0)
            $0.height.equalTo(view.bounds.height-30)
        }
    }

    //返回标签数组
    func segmentTitles() -> [String] {
        return ["这是标签1", "标签2", "这是标签3", "标签4", "这是标签5", "标签6", "这是标签7"]
    }
    //返回vc数组
    func segmentControllers() -> [UIViewController] {
        var arr = [ViewControllerItem]()
        for str in segmentTitles() {
            let vc = ViewControllerItem()
            vc.t = str
            arr.append(vc)
        }
        return arr
    }
}

